import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from '@/pages/Home'
import Search from '@/pages/Search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'


Vue.use(VueRouter)

const router = new VueRouter({
    routes: [
        {
            path: '*',
            redirect: "/home"
        },
        {
            name: 'home',
            path: '/home',
            component: Home,
            meta: {
                show: true,
            }
        },
        {
            name: 'search',
            path: '/search/:keyword',
            component: Search,
            meta: {
                show: true,
            }
            //路由组件传参的时候传props。
        },
        {
            name: 'login',
            path: '/login',
            component: Login,
            meta: {
                show: false,
            }
        },
        {
            name: 'register',
            path: '/register',
            component: Register,
            meta: {
                show: false,
            }
        },
    ]
})

export default router